fix(types): resolve request declaration errors - #19495
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. Walkthrough本次变更调整网络请求类型声明。 Changes网络请求类型
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized type-definition fix restores request API compatibility without changing runtime behavior, networking, permissions, or deployment behavior. No actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
这个 PR 做了什么? (简要描述所做更改)
Fixes #18565.
packages/taro/types/api/network/request.d.ts在严格类型检查下存在 5 个声明错误:Chain两处引用未声明的RequestParams;Option、RequestTask和TaroStatic.request的外层泛型未受约束,却被传给受约束的内部泛型,产生 3 个TS2344。本 PR:
RequestParams<T>,继续继承request.Option<T, any>并允许拦截器附加自定义字段;Option<T, U>与SuccessCallbackResult<T>对齐现有公开签名Taro.request<T = any, U = any>,移除造成声明自相矛盾的内部约束;data: U、HTTP method 等字段级类型校验,不改变运行时代码。选择对齐现有无约束公开泛型,而不是向外传播约束,可以避免对已有自定义响应/请求类型造成 breaking change。
验证
origin/main复现 5 errors,当前分支 0 errors;@ts-expect-error确认错误 request data 与 method 仍被拒绝;corepack pnpm exec prettier --check packages/taro/types/api/network/request.d.ts;corepack pnpm lint;corepack pnpm --filter @tarojs/api test:ci(2 suites / 7 tests);corepack pnpm pack,确认发布包包含修复后的声明。这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit